<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>My JSP 'login.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <style>
        #div1{
            border: 3px #FF5722 solid;
            width: 500px;
            height: 300px;
            margin: 0 auto;
            position: absolute;
            top:150px;
            left:500px;
            text-align: center;
        }
        form{
            position: absolute;
            top:40px;
            left:120px;
        }
    </style>


</head>

<body class="login">
<div id="div1">
    <form  id="from" method="post">

        <table>
            <tr>
                <td>
                    <h5>用户名:</h5>
                    <input type="text" name="userCode" placeholder="请输入密码">
                </td>
            </tr>
            <tr>
                <td>
                    <h5>密码:</h5>
                    <input type="password" name="userPassword" placeholder="请输入密码">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" id="btn" value="登陆"/>
                    <input type="reset" value="重填"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script src="static/js/jquery-1.12.4.js"></script>

<script type="text/javascript">
    $(function(){

        $("#btn").click(function(){

            var arr = $("#from").serializeArray();
            $.ajax({
                url:"logins",
                data:arr,
                dataType:"JSON",
                type:"POST",
                success:function(data){

                    if(data=="ok"){
                        alert("登陆成功");
                        window.location.href="main";
                    }else{
                        alert("登陆失败");
                    }
                }
            });

        });

    });
</script>
</html>






